﻿@inherits Vowei.Web.G18nWebViewPage<Vowei.Core.Models.Task>
@using System.Web.Mvc.Html 
@using Vowei.Core.Models
@using Vowei.Web.Models
@using Vowei.Web.Helpers

@{
    ViewBag.Title = T("编辑任务详细信息");
}

<form method="post" action="/Task/Edit">
    <div id="viewpot">
        <!-- place holder for template generated html -->
    
	    <p>
		    <input type="submit" name="submit_btn" id="submit_btn" value="@T("保存")" />
	    </p>
    </div>
</form>

@{
    this.WriteClientTemplate("Task", "Edit");
    this.WriteClientTemplateScript();
}

<script type="text/html" id="milestone_tmpl">	
    <select name="BelongsToMilestone.ID" id="BelongsToMilestone.ID">
        {{each dataContext}}
        <option value="${ID}">${Title}</option>
        {{/each}}
    </select>
</script>

<script language="javascript" type="text/javascript">
    @{        
        var milestoneText = new HtmlString((string)ViewData["Milestones"]);   
    }

    // 添加milestone 列表的支持
    var milestones = @milestoneText;
    $('#milestone_tmpl').tmpl({ dataContext: milestones }).appendTo('#milestone_list');

    @if ( @Model.BelongsToMilestone != null ) {
        Html.Raw(string.Format("$.each($('Milestone.ID').children('option'), function(i, o) {{ " +
             "    if ( $(this).val() == '{0}' ) {{ " +
             "         $(this).attr('selected', 'selected'); " +
             "         return; " +
             "    }} " +
             "}});", Model.BelongsToMilestone.ID));
    }    
    
    $.each($('#Task_Status').children('option'), function(i, o) {
       if ( $(this).val() == "@Model.Status" ) {
           $(this).attr('selected', 'selected');
           return;
       }
    });
</script>